#!/bin/bash

phoenix_url="git clone ssh://anl@192.168.8.250:29418/phoenix"
lbcloud_url="git clone ssh://anl@192.168.8.250:29418/cloud"
tob_url="git clone ssh://anl@192.168.8.250:29418/windows"

cur_path=`pwd`
echo input is $1
if  [ "x$1" == "x" ]; then 
    echo " sh code_pull.sh rec_sdk/rec_app/send_app/send_sdk/ios_app/ios_sdk "
    echo "                 ad/auth/common/data/go/pay/plat/lbcloud"
    echo "                  pp_sdk/pp_app/win_app/win_sdk/rsdk" 
    echo "                  all_branches" 
    exit 1
fi 

[ $1 == "rec_sdk" ] && rm SDK -rf && $phoenix_url/SDK && cd SDK && git checkout develop && git branch
[ $1 == "rec_app" ] &&  rm AndroidReceiver -rf  && $phoenix_url/standard/AndroidReceiver  && cd AndroidReceiver && git checkout develop && git branch
[ $1 == "send_sdk" ] && rm source -rf &&  $phoenix_url/standard/sdk/source && cd source && git checkout develop && git branch
[ $1 == "send_app" ] &&  rm AndroidSender -rf &&	$phoenix_url/standard/AndroidSender && cd AndroidSender && git checkout develop && git branch
[ $1 == "ios_app" ] &&   rm AppleSenderApp -rf &&  $phoenix_url/AppleSenderApp && cd AppleSenderApp && git checkout develop  && git branch
[ $1 == "ios_sdk" ] &&  rm AppleSenderSDK -rf &&  $phoenix_url/AppleSenderSDK && cd AppleSenderSDK && git checkout develop && git branch

[ $1 == "ad" ] && rm LBCloud-AD -rf && $lbcloud_url/LBCloud-AD && cd LBCloud-AD && git checkout develop && git branch
[ $1 == "auth" ] && rm LBCloud-Auth -rf && $lbcloud_url/LBCloud-Auth && cd LBCloud-Auth && git checkout develop && git branch
[ $1 == "common" ] && rm LBCloud-Common -rf && $lbcloud_url/LBCloud-Common && cd LBCloud-Common && git checkout develop && git branch
[ $1 == "data" ] && rm LBCloud-Data -rf && $lbcloud_url/LBCloud-Data && cd LBCloud-Data  && git checkout develop && git branch
[ $1 == "go" ] && rm LBCloud-Go -rf && $lbcloud_url/LBCloud-Go && cd LBCloud-Go  && git checkout develop && git branch
[ $1 == "pay" ] && rm LBCloud-Pay -rf && $lbcloud_url/LBCloud-Pay && cd LBCloud-Pay && git checkout develop && git branch
[ $1 == "plat" ] && rm LBCloud-Plat -rf && $lbcloud_url/LBCloud-Plat  && cd LBCloud-Plat && git checkout develop && git branch
[ $1 == "lbcloud" ] && rm LBCloud -rf && git clone ssh://anl@192.168.8.250:29418/windows/LBCloud 

[ $1 == "pp_sdk" ] && rm ToB-PP -rf && $tob_url/ToB-PP 
[ $1 == "pp_app" ] && rm ToB-PP-App -rf && $tob_url/ToB-PP-App
[ $1 == "win_sdk" ] && rm ToB-Win-Sdk -rf && $tob_url/ToB-Win-Sdk
[ $1 == "win_app" ] && rm ToB-Win-App -rf && $tob_url/ToB-Win-App
[ $1 == "rsdk" ] && rm ToB-RSDK -rf && $tob_url/ToB-RSDK

if [ $1 == "all_branches" ]; then 
    var_list="AndroidReceiver AndroidSender AppleSenderApp AppleSenderSDK SDK source LBCloud LBCloud-AD LBCloud-Auth LBCloud-Common LBCloud-Data \
LBCloud-Go LBCloud-Pay LBCloud-Plat ToB-PP ToB-PP-App ToB-RSDK ToB-Win-App ToB-Win-Sdk"
for var_repo in $var_list
    do 
        
        cd $var_repo
	#echo $var_repo branches num:
        git branch -a |grep  remotes/origin |grep -v remotes/origin/HEAD |wc -l
        cd $cur_path
    done
fi 
 	









